

package com.loong.loong.hik.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.loong.loong.common.core.util.R;
import com.loong.loong.common.log.annotation.SysLog;
import com.loong.loong.hik.entity.HikCdcTempHum;
import com.loong.loong.hik.service.HikCdcTempHumService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.loong.loong.common.excel.annotation.ResponseExcel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 温湿度

 *
 * @author dxy
 * @date 2023-04-12 15:30:07
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/hikcdctemphum" )
@Api(value = "hikcdctemphum", tags = "温湿度管理")
public class HikCdcTempHumController {

    private final  HikCdcTempHumService hikCdcTempHumService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param hikCdcTempHum 温湿度

     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdctemphum_view')" )
    public R getHikCdcTempHumPage(Page page, HikCdcTempHum hikCdcTempHum) {
        return R.ok(hikCdcTempHumService.page(page, Wrappers.query(hikCdcTempHum)));
    }


    /**
     * 通过id查询温湿度

     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdctemphum_view')" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(hikCdcTempHumService.getById(id));
    }

    /**
     * 新增温湿度

     * @param hikCdcTempHum 温湿度

     * @return R
     */
    @ApiOperation(value = "新增温湿度", notes = "新增温湿度")
    @SysLog("新增温湿度 ")
    @PostMapping
    @PreAuthorize("@pms.hasPermission('hik_hikcdctemphum_add')" )
    public R save(@RequestBody HikCdcTempHum hikCdcTempHum) {
        return R.ok(hikCdcTempHumService.save(hikCdcTempHum));
    }

    /**
     * 修改温湿度

     * @param hikCdcTempHum 温湿度

     * @return R
     */
    @ApiOperation(value = "修改温湿度", notes = "修改温湿度")
    @SysLog("修改温湿度 " )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('hik_hikcdctemphum_edit')" )
    public R updateById(@RequestBody HikCdcTempHum hikCdcTempHum) {
        return R.ok(hikCdcTempHumService.updateById(hikCdcTempHum));
    }

    /**
     * 通过id删除温湿度

     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除温湿度 ", notes = "通过id删除温湿度 ")
    @SysLog("通过id删除温湿度 " )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdctemphum_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(hikCdcTempHumService.removeById(id));
    }


    /**
     * 导出excel 表格
     * @param hikCdcTempHum 查询条件
     * @return excel 文件流
     */
    @ResponseExcel
    @GetMapping("/export")
    @PreAuthorize("@pms.hasPermission('hik_hikcdctemphum_export')" )
    public List<HikCdcTempHum> export(HikCdcTempHum hikCdcTempHum) {
        return hikCdcTempHumService.list(Wrappers.query(hikCdcTempHum));
    }
}
